package com.xuyiwei.mayi.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
 * Created by xuyiwei on 2019/4/23.
 */
@SuppressWarnings("unchecked")
@Service
public class MemberService {
    @Autowired
    private RestTemplate restTemplate;

    public List<String> getOrderByUserList() {
        return restTemplate.getForObject("http://service-member/getUserList", List.class);
    }

    @HystrixCommand(fallbackMethod = "getPortError")
    public String getPort() {
        return restTemplate.getForObject("http://service-member/getPort", String.class);
    }

    public String getPortError() {
        return "service-member服务调用错误";
    }
}
